package com.cjm.algorithm.dp;

import java.util.List;

public class Ti139 {
    public static void main(String[] args) {

    }
    public boolean wordBreak(String s, List<String> wordDict) {
        boolean[] dp = new boolean[s.length()];
        for (int i = 0; i < dp.length; i++) {
            dp[i] = false;
        }
        dp[0] = true;
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < i; j++) {
                String word = s.substring(j, i -j);
                if (word.contains(word) && dp[j]) {
                    dp[i] = true;
                }
            }
        }
        return dp[s.length() - 1];
    }
}
